<template>
    <el-table :data="students" style="width: 100%">
        <el-table-column prop="name" label="姓名" />
        <el-table-column prop="gender" label="性别" />
        <el-table-column prop="age" label="年龄" />
        <el-table-column prop="classes.name" label="班级" />
        <el-table-column label="Operations">
            <template #default="scope">
                <el-button size="small" @click="handleEdit(scope.row._id)">修改</el-button>
                <el-button size="small" type="danger" @click="handleDelete(scope.row._id)">删除</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>
<script setup>
import { storeToRefs } from 'pinia';
import {defineProps} from 'vue';
import { useStudentStore } from '../../stores/student';
const props = defineProps(['students']);
const studentStore = useStudentStore();
const {setUpdateVisible,fetchStudent} = studentStore;
function handleEdit(id){
    setUpdateVisible(true);
    fetchStudent(id);
}
</script>